package com.yangtao.springbootfreemarker.domain.sys.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.yangtao.core.jpa.OriginalBaseEntity;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "sys_user")
public class SysUser extends OriginalBaseEntity<SysUser> {

	public static final String SHOW_PASSWORD = "____________";

	@Id
	@GenericGenerator(name="idGenerator", strategy="uuid") //这个是hibernate的注解/生成32位UUID
	@GeneratedValue(generator="idGenerator")
	@Column(name = "user_id")
	private String userId;

	@Column(name = "username")
	private String username; // 用户名

	@JSONField(serialize = false)
	@Column(name = "password")
	private String password; // 密码

	@Column(name = "name")
	private String name; // 姓名

	@JSONField(serialize = false)
	@Column(name = "salt")
	private String salt; // 盐

	@Column(name = "email")
	private String email;

	@Column(name = "mobile")
	private String mobile;

	@Column(name = "status")
	private Integer status; // 状态  0：禁用   1：正常

	@Transient
	private List<String> roleIdList; // 角色ID列表

	@Column(name = "create_time")
	private Date createTime; // 创建时间

	@Column(name = "dept_id")
	private String deptId;

	@Transient
	private String deptName; // 部门名称

	@Column(name = "user_type")
	private String userType;

	@Column(name = "org_id")
	private String orgId;

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public List<String> getRoleIdList() {
		return roleIdList;
	}

	public void setRoleIdList(List<String> roleIdList) {
		this.roleIdList = roleIdList;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getDeptId() {
		return deptId;
	}

	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	/**
	 * 用户状态枚举
	 */
	public enum Status {
		DISABLE(0), ENABLE(1);
		private Integer value;

		Status(Integer value) {
			this.value = value;
		}
		public Integer getValue() {
			return value;
		}

		public void setValue(Integer value) {
			this.value = value;
		}
	}
}
